import {reqGetUserInfo} from '@/api';

export default {
    namespaced: true,
    state: {
        allUserInfo: {
            id: '',
            username: '',
            password: '',
            phone: '',
            address: '',
            orderInfo: '',
            integral: '',
            gender: ''
        }
    },
    mutations: {
        setAllUserInfo(state, allUserInfo) {
            state.allUserInfo = allUserInfo;
        }
    },
    actions: {
        async asyncAllSetUserInfo({commit}, id) {
            let res = await reqGetUserInfo({id});
            if (res.status === 200) {
                commit('setAllUserInfo', res.data);
            }
        }
    },
    getters: {
        username(state) {
            return state.allUserInfo.username;
        },
        integral(state) {
            return state.allUserInfo.integral;
        },
        address(state) {
            return state.allUserInfo.address;
        }
    }
}